﻿namespace EFMLEditor.Internal.Validating.Attributes
{
    using System.Reflection;

    public class StartsWithAttribute : ValidatingAttribute
    {
        private readonly string starts;

        public StartsWithAttribute(string startss)
        {
            this.starts = startss;
        }

        #region Overrides of ValidatingAttribute

        public override bool Do(object input, ParameterInfo parameter)
        {
            var l = input.ToString();
            if (l.Contains(starts))
            {
                return true;
            }
            this.Message = parameter.Name + " must start with " + starts;
            return false;
        }

        #endregion
    }
}